<template>
  <m-transfer
    v-model="value"
    :config="config"
  ></m-transfer>
</template>

<script>
  import _ from 'lodash'
  import mTransfer from '@/module/components/mTransfer'
  import { mapActions } from 'vuex'
  export default {
    name: 'UDF',
    components: { mTransfer },
    data () {
      return {
        value: [],
        config: {
          data: [],
          titles: ['项目列表', '已选项目']
        },
        transferData: {
          sourceListPrs: [],
          targetListPrs: [],
          type: {
            name: ''
          }
        },
      }
    },
    inject: ['roleInfo', 'item'],
    created () {
      this._authUdfFunc()
    },
    watch: {
      value: function (v) {
        this.$store.commit('permission/setPermissions', { UDF: this.value })
      }
    },
    methods: {
      ...mapActions('security', ['deleteUser', 'getAuthList', 'grantAuthorization', 'getResourceList']),
      _authUdfFunc (item, i) {
        this.getAuthList({
          id: 89,
          type: 'udf-func',
          category: 'resources'
        }).then(data => {
          let sourceListPrs = _.map(data[0], v => {
            return {
              key: v.id,
              label: v.funcName,
              disabled: false
            }
          })
          let targetListPrs = _.map(data[1], v => {
            return {
              key: v.id,
              label: v.funcName,
              disabled: false
            }
          })
          this.item = item
          this.value = targetListPrs
          this.config.data = sourceListPrs
        }).catch(e => {
          this.$message.error(e.msg || '')
        })
      },
    },
  }
</script>
<style scoped lang=''>
</style>
